package com.hj.homework;

public class Test4 {
    public static void main(String[] args) {
        Person2[] person2s = {new Man2(),new Man2(),new Woman2(),new Woman2(),new Man2()};
        meeting(person2s);
    }

    public static void meeting(Person2[] ps) {
        for (Person2 p : ps) {
            p.eat();
            p.toilet();
            if (p instanceof Man2) {
                ((Man2) p).smoke();
            } else if (p instanceof Woman2) {
                ((Woman2) p).makeup();
            }
            System.out.println();
        }
    }
}
class Person2{
    public void eat(){
        System.out.println("吃饭");
    }
    public void toilet(){
        System.out.println("上洗手间");
    }
}
class Man2 extends Person2{
    @Override
    public void eat() {
        super.eat();
    }

    @Override
    public void toilet() {
        super.toilet();
    }
    public void smoke(){
        System.out.println("抽烟");
    }
}
class Woman2 extends Person2{
    @Override
    public void eat() {
        super.eat();
    }

    @Override
    public void toilet() {
        super.toilet();
    }
    public void makeup(){
        System.out.println("化妆");
    }
}
